#include <stdio.h>
#include <conio.h>
#include <stdbool.h>

void testPrime(void) ;
void viewPrime(void) ;

int main() {
	int a ;
	char ans ;
	
	startover :
	
	printf("1- test your number\n");
	printf("2- view Prime numbers\n");
	scanf("%d", &a);
	switch ( a ) {
		case 1 :
			testPrime();
			break ;
		case 2 :
			viewPrime();
			break;
	}
	
	
		
	printf("\nwould you like to start over ? Y/N \n");
	scanf(" %c", &ans);
	if( ans == 'Y' || ans == 'y')
		goto startover;
		
	getchar();
	return 0;
}

void testPrime(void) {
	bool isPrime ;
	int  numbr ;
	
	
		printf("enter the number that wan to check ( except 1 and 2) : \n");
		scanf("%d", &numbr);
		if ( numbr == 1 || numbr == 2 )
			printf("eshtebah zadi dadach\n");
		isPrime = ( numbr % 2 == 0) ? false : true ;
		
		if ( isPrime == false )
			printf("the number is not Prime\n");
		else 
			printf("number is Prime\n");
		
}

void viewPrime(void) {
	int i , j , Numbr;
	bool isPrime ;
	
	printf("enter a number :\n");
	scanf(" %d", &Numbr);
	for( i = 2 ; i < Numbr ; i++) {
		isPrime = true ;
		for( j = 2 ; j < i ; j++)
			if( i%j == 0)
				isPrime = false ;
				
			if( isPrime != false)
				printf("%d  ", i);
	}
	
}
